import Api from '@/axios'

const user = {
  state: {
    userName: 'userNamexxx',
    userInfo: null
  },
  mutations: {
    getConfigData(state) {
      Api.getUserinfo().then(res => {
        let result = res.data
        if (res.data.code === 0) {
          state.userInfo = result.data
        } else {
          console.log(result.message)
        }
      })
    },
    handleClearUserinfo(state) {
      localStorage.clear()
      state.userInfo = null
    }
  },
  actions: {
    getConfiglist(context) {
      context.commit('getConfigData')
    }
  }
}
export default user
